import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/Home/index.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: HomeView
  },
  {
    path: '/home/search',
    name: 'Search',
    component: () => import(/* webpackChunkName: "about" */ '../views/Home/search/index.vue')
  },
  {
    path: '/home/list',
    name: 'List',
    component: () => import(/* webpackChunkName: "about" */ '../views/Home/list/index.vue')
  },
  {
    path: '/home/map',
    name: 'Map',
    component: () => import(/* webpackChunkName: "about" */ '../views/Home/mapGuide/index.vue')
  },
  {
    path: '/home/goodsDetail',
    name: 'goodsDetail',
    component: () => import(/* webpackChunkName: "about" */ '../views/Home/goodsDetail/index.vue')
  },

  {
    path: '/topic',
    name: 'Topic',
    component: () => import(/* webpackChunkName: "about" */ '../views/Topic/index.vue')
  },
  {
    path: '/topic/topicList',
    name: 'TopicList',
    component: () => import('../views/Topic/TopicList/index.vue')
  },
  {
    path: '/home/brand',
    name: 'brand',
    component: () => import('../views/Home/brand/index.vue')
  },
  {
    path: '/home/brandList',
    name: 'brandList',
    component: () => import('../views/Home/brand/index.vue')
  },
  {
    path: '/kind',
    name: 'Kind',
    component: () => import(/* webpackChunkName: "about" */ '../views/Kind/index.vue')
  },
  {
    path: '/kind/list',
    name: 'KindList',
    component: () => import('../views/Kind/list/')
  },
  {
    path: '/cart',
    name: 'Cart',
    component: () => import(/* webpackChunkName: "about" */ '../views/Cart/index.vue')
  },
  {
    path: '/cart/order',
    name: 'Order',
    component: () => import(/* webpackChunkName: "about" */ '../views/Cart/order/index.vue')
  },
  {
    path: '/user',
    name: 'User',
    component: () => import(/* webpackChunkName: "about" */ '../views/User/index.vue')
  },
  {
    path: '/user/address',
    name: 'Address',
    component: () => import(/* webpackChunkName: "about" */ '../views/User/address/index.vue')
  },
  {
    path: '/user/opinion',
    name: 'Opinion',
    component: () => import(/* webpackChunkName: "about" */ '../views/User/opinion/index.vue')
  },
  {
    path: '/user/collect',
    name: 'Collect',
    component: () => import(/* webpackChunkName: "about" */ '../views/User/collect/index.vue')
  }

]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})

export default router
